home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / VELENG10.ZIP / DEBUG.H < prev    next >
C/C++ Source or Header  |  1997-07-27  |  7KB  |  205 lines

  1. /****************************************************************************
  2. *
  3. *                   Copyright (C) 1993 SciTech Software
  4. *                           All rights reserved.
  5. *
  6. * Filename:     $RCSfile: debug.h $
  7. * Version:      $Revision: 1.3 $
  8. *
  9. * Language:     ANSI C
  10. * Environment:  any
  11. *
  12. * Description:  General header file for portable code.
  13. *
  14. * $Id: debug.h 1.3 1994/08/22 07:57:55 kjb release $
  15. *
  16. ****************************************************************************/
  17.  
  18. #ifndef __DEBUG_H
  19. #define __DEBUG_H
  20.  
  21. #ifdef  DEBUG
  22. #       define DBG(x) x
  23. #else
  24. #       define DBG(x)
  25. #endif
  26.  
  27. #if     defined(__MSDOS__) || defined(__DOS__) || defined(M_I86)
  28. #ifndef    __MSDOS__
  29. #        define __MSDOS__
  30. #endif
  31. #       define MS(x) x
  32. #       define OS(x)
  33. #       define UX(x)
  34. #       define IR(x)
  35. #       define _8086        /* We know we have an 8086 type processor   */
  36. #if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  37. #       define LDATA
  38. #ifndef NULL
  39. #       define NULL 0L
  40. #endif
  41. #else
  42. #ifndef NULL
  43. #       define NULL 0
  44. #endif
  45. #if defined(DJGPP) || defined(EMX)
  46. #       define near
  47. #       define far
  48. #       define cdecl
  49. #        define _cdecl
  50. #endif
  51. #endif
  52. #elif   defined(__OS2__)        /* Compiling for 32 bit OS/2            */
  53. #       define MS(x)
  54. #       define OS(x) x
  55. #       define UX(x)
  56. #       define IR(x)
  57. #       define _80386       /* We know we have an 80386 type processor  */
  58. #       define MAXFILE  255     /* These are defined in <dir.h>, but    */
  59. #       define MAXDIR   255     /* on OS/2 machines, we just define     */
  60. #       define MAXPATH  255     /* them all to be the same size         */
  61. #       define near             /* Near and far do not exist under      */
  62. #       define far              /* 32 bit OS/2                          */
  63. #ifndef NULL
  64. #       define NULL 0L
  65. #endif
  66. #else                           /* Assume UNIX compilation              */
  67. #       define MS(x)
  68. #       define OS(x)
  69. #       define UX(x) x
  70. #if     defined(__IRIS4D__)     /* Compiling for the SGI Iris 4D        */
  71. #       define IR(x) x
  72. #else
  73. #       define IR(x)
  74. #endif
  75. #       define O_BINARY 0       /* no binary input mode in UNIX open()  */
  76. #       define MAXFILE  255     /* These are defined in <dir.h>, but    */
  77. #       define MAXDIR   255     /* on UNIX machines, we just define     */
  78. #       define MAXPATH  255     /* them all to be the same size         */
  79. #       define far              /* Near and far do not exist under      */
  80. #       define near             /* UNIX or the Iris.                    */
  81. #       define cdecl
  82. #        define _cdecl
  83. #ifndef NULL
  84. #       define NULL ((void *)0)
  85. #endif
  86. #define    PUBAPI                    /* UNIX has no _cdecl keywords            */
  87. #endif
  88.  
  89. #define PRIVATE static
  90. #define PUBLIC
  91.  
  92. /* PUBAPI is used to declare calling conventions used for publicly
  93.  * accessible functions. You can override this from the command line to
  94.  * compile with another calling convetion (note that if you change this
  95.  * declaration you will need to re-compile all libraries with the same
  96.  * calling conventions). By default we use the default calling conventions
  97.  * for the compiler being used (Watcom uses register based conventions
  98.  * by default).
  99.  */
  100.  
  101. #ifndef    PUBAPI
  102. #define PUBAPI                  /* Use default calling conventions      */
  103. #endif
  104.  
  105. /****************************************************************************
  106. *
  107. *   SEG(p)      Evaluates to the segment portion of an 8086 address.
  108. *   OFF(p)      Evaluates to the offset portion of an 8086 address.
  109. *   FP(s,o)     Creates a far pointer given a segment offset pair.
  110. *   PHYS(p)     Evaluates to a long holding a physical address
  111. *
  112. ****************************************************************************/
  113.  
  114. #ifdef  _8086
  115. #       define SEG(p)   ( (unsigned)(((unsigned long)((void far *)(p))) >> 16))
  116. #       define OFF(p)   ( (unsigned)(p) )
  117. #       define FP(s,o)  ( (void far *)( ((unsigned long)(s) << 16) +  \
  118.                           (unsigned long)(o) ))
  119. #       define PHYS(p)  ( (unsigned long)OFF(p) +                       \
  120.                           ((unsigned long)SEG(p) << 4))
  121. #else
  122. #       define PHYS(p)  (p)
  123. #endif  /* _8086 */
  124.  
  125. /****************************************************************************
  126. *
  127. *   NUMELE(array)       Evaluates to the array size in elements
  128. *   LASTELE(array)      Evaluates to a pointer to the last element
  129. *   INBOUNDS(array,p)   Evaluates to true if p points into the array
  130. *   RANGE(a,b,c)        Evaluates to true if a <= b <= c
  131. *   MAX(a,b)            Evaluates to a or b, whichever is larger
  132. *   MIN(a,b)            Evaluates to a or b, whichever is smaller
  133. *   ABS(a)              Evaluates to the absolute value of a
  134. *   NBITS(type)         Returns the number of bits in a variable of the
  135. *                       indicated type
  136. *   MAXINT              Evaluates to the value of the largest signed integer
  137. *
  138. ****************************************************************************/
  139.  
  140. #define NUMELE(a)       (sizeof(a)/sizeof(*(a)))
  141. #define LASTELE(a)      ((a) + (NUMELE(a)-1))
  142. #ifdef  LDATA
  143. #define TOOHIGH(a,p)    ((long)PHYS(p) - (long)PHYS(a) > (long)(NUMELE(a)-1))
  144. #define TOOLOW(a,p)     ((long)PHYS(p) - (long)PHYS(a) < 0)
  145. #else
  146. #define TOOHIGH(a,p)    ((long)(p) - (long)(a) > (long)(NUMELE(a)-1))
  147. #define TOOLOW(a,p)     ((long)(p) - (long)(a) < 0)
  148. #endif
  149. #define INBOUNDS(a,p)   ( ! (TOOHIGH(a,p) || TOOLOW(a,p)) )
  150.  
  151. #define _IS(t,x) (((t)1 << (x)) != 0)   /* Evaluates true if the width of */
  152.                                         /* variable of type t is < x.     */
  153.                                         /* The != 0 assures that the      */
  154.                                         /* answer is 1 or 0               */
  155.  
  156. #define NBITS(t) (4 * (1 + _IS(t,4) + _IS(t,8) + _IS(t,12) + _IS(t,16) \
  157.                          + _IS(t,20) + _IS(t,24) + _IS(t,28) + _IS(t,32)))
  158.  
  159. #define MAXINT          (((unsigned)~0) >> 1)
  160.  
  161. #ifndef MAX
  162. #       define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
  163. #endif
  164. #ifndef MIN
  165. #       define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
  166. #endif
  167. #ifndef ABS
  168. #       define ABS(a)   ((a) >= 0 ? (a) : -(a))
  169. #endif
  170. #ifndef    SIGN
  171. #        define SIGN(a)    ((a) > 0 ? 1 : -1)
  172. #endif
  173.  
  174. #define RANGE(a,b,c)    ( (a) <= (b) && (b) <= (c) )
  175.  
  176. /* General typedefs */
  177.  
  178. #ifndef __GENDEFS
  179. #define __GENDEFS
  180. typedef unsigned char   uchar;
  181. typedef unsigned short  ushort;
  182. typedef unsigned int    uint;
  183. typedef unsigned long   ulong;
  184. #ifndef    CLASSLIB_DEFS_H
  185. typedef short            bool;
  186. #endif
  187. #endif  /* __GENDEFS */
  188.  
  189. /* Boolean truth values */
  190.  
  191. #undef    false
  192. #undef    true
  193. #undef    FALSE
  194. #undef    TRUE
  195. #undef    NO
  196. #undef    YES
  197. #define false       ((bool)0)
  198. #define true        ((bool)1)
  199. #define FALSE       ((bool)0)
  200. #define TRUE        ((bool)1)
  201. #define NO          ((bool)0)
  202. #define YES         ((bool)1)
  203.  
  204. #endif  /* __DEBUG_H */
  205.